const xhlConster = function () {
  window.beforeXMLHttpRequestOpen = function (xhr, options) {
    // 修改method
    // options.method = 'POST';
  };
  /**
   * 拦截并修改ajax请求
   */
  // var a = Object.prototype.toString;
  window.beforeXMLHttpRequestSend = function (xhr, body) {
    // const sptueurls = xhr.__sentry_xhr__.url.split('?')[0]

    // onload 获取请求结果
    xhr.onload = (res => {
      // console.log('请求结果', res)
    })

  };

  /**
   * 重写open方法
   * https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest/open
   */
  XMLHttpRequest.prototype.myOpen = XMLHttpRequest.prototype.open;
  XMLHttpRequest.prototype.open = function (method, url, async, user, password) {
    // 用对象便于修改参数
    var options = {
      method: method,
      url: url,
      async: async,
      user: user,
      password: password
    };
    if ('function' === typeof window.beforeXMLHttpRequestOpen) {
      window.beforeXMLHttpRequestOpen(this, options);
    }
    this.myOpen(options.method, options.url, options.async)
  };

  XMLHttpRequest.prototype.mySend = XMLHttpRequest.prototype.send;
  XMLHttpRequest.prototype.send = function (body) {
    if ('function' === typeof window.beforeXMLHttpRequestSend) {
      window.beforeXMLHttpRequestSend(this, body);
    }
    this.mySend(body)
  };

}
export default xhlConster